package kevin.ecstorm.pdd.rest;

import com.alibaba.fastjson.JSON;
import com.pdd.pop.sdk.http.api.request.PddErpOrderSyncRequest;
import com.pdd.pop.sdk.http.api.request.PddOrderInformationGetRequest;
import com.pdd.pop.sdk.http.api.request.PddOrderListGetRequest;
import com.pdd.pop.sdk.http.api.request.PddOrderNumberListIncrementGetRequest;
import com.pdd.pop.sdk.http.api.response.PddErpOrderSyncResponse;
import com.pdd.pop.sdk.http.api.response.PddOrderInformationGetResponse;
import com.pdd.pop.sdk.http.api.response.PddOrderListGetResponse;
import com.pdd.pop.sdk.http.api.response.PddOrderNumberListIncrementGetResponse;
import kevin.ecstorm.pdd.config.PddAppAuth;
import kevin.ecstorm.pdd.service.IPddService;
import kevin.ecstorm.pdd.service.IPrintOrderService;
import kevin.framework.core.web.JsonResponse;
import kevin.framework.core.web.RestDoing;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ©Copyright ©1968-2020 Midea Group,IT
 * FileName: PddOrder
 * Author: kevin
 * Date: 2020年03月15日 01:25:16
 * Description: PddOrder服务接口
 */
@RestController
@RequestMapping("/pdd")
public class PddOrderRest {
    @Autowired
    private IPddService pddService;
    @Autowired
    private PddAppAuth auth;

    /**
     * 订单列表查询接口（根据成交时间）
     * @param param
     * @return
     */
    @GetMapping("/order/list/get")
    public PddOrderListGetResponse listGet(PddOrderListGetRequest param) {
        return pddService.syncInvoke(param, auth);
    }

    /**
     * 订单详情
     * @param param
     * @return
     */
    @GetMapping("/order/information/get")
    public PddOrderInformationGetResponse listGet(PddOrderInformationGetRequest param) {
        return pddService.syncInvoke(param, auth);
    }

    /**
     * erp打单信息同步
     * @param param
     * @return
     */
    @GetMapping("/erp/order/sync")
    public PddErpOrderSyncResponse erpOrderSync(PddErpOrderSyncRequest param) {
        return pddService.syncInvoke(param, auth);
    }

    /**
     * 订单增量接口
     * @param param
     * @return
     */
    @GetMapping("/order/number/list/increment/get")
    public PddOrderNumberListIncrementGetResponse pddOrderNumberListIncrementGet(PddOrderNumberListIncrementGetRequest param) {
        return pddService.syncInvoke(param, auth);
    }

    /**
     * 订单状态
     * @param param
     * @return
     */
    @GetMapping("/order/status/get")
    public PddOrderNumberListIncrementGetResponse pddOrderStatusGet(PddOrderNumberListIncrementGetRequest param) {
        return pddService.syncInvoke(param, auth);
    }

    @GetMapping("/pddOrderListTest")
    public JsonResponse pddOrderListTest(PddOrderListGetRequest param) {
        String s = "{\"orderListGetResponse\":{\"hasNext\":false,\"orderList\":[{\"address\":\"\",\"afterSalesStatus\":0,\"buyerMemo\":\"\",\"capitalFreeDiscount\":0.0,\"cardInfoList\":[],\"catId1\":7639,\"catId2\":7646,\"catId3\":7861,\"catId4\":8136,\"city\":\"\",\"cityId\":85,\"confirmStatus\":1,\"confirmTime\":\"2020-02-23 20:52:54\",\"country\":\"中国\",\"countryId\":0,\"createdTime\":\"2020-02-22 20:53:46\",\"discountAmount\":0.0,\"freeSf\":0,\"goodsAmount\":12.7,\"groupStatus\":1,\"homeDeliveryType\":0,\"innerTransactionId\":\"XP0020022220200259238967006624\",\"invoiceStatus\":0,\"isLuckyFlag\":1,\"isPreSale\":0,\"isStockOut\":0,\"itemList\":[{\"goodsCount\":1,\"goodsId\":\"8336081475\",\"goodsImg\":\"https://t00img.yangkeduo.com/goods/images/2019-01-11/7d236579-2014-48bf-aa75-91254fb08197.jpg\",\"goodsName\":\"张学友刘德华周杰伦陈奕迅精选汽车CD碟片流行港台明粤语经典老歌\",\"goodsPrice\":12.7,\"goodsSpec\":\"张学友=2碟\",\"outerGoodsId\":\"\",\"outerId\":\"0\",\"skuId\":\"231294322836\"}],\"lastShipTime\":\"2020-02-26 23:59:59\",\"logisticsId\":85,\"onlySupportReplace\":0,\"orderSn\":\"200222-332214436973404\",\"orderStatus\":3,\"payAmount\":12.7,\"payNo\":\"2020022222001414241423393420\",\"payTime\":\"2020-02-22 20:53:53\",\"payType\":\"ALIPAY\",\"platformDiscount\":0.0,\"postage\":0.0,\"preSaleTime\":\"\",\"province\":\"\",\"provinceId\":6,\"receiveTime\":\"2020-02-29 18:26:39\",\"receiverAddress\":\"\",\"receiverName\":\"\",\"receiverPhone\":\"\",\"refundStatus\":1,\"remark\":\"\",\"returnFreightPayer\":1,\"riskControlStatus\":0,\"selfContained\":0,\"sellerDiscount\":0.0,\"shippingTime\":\"2020-02-25 14:20:45\",\"stockOutHandleStatus\":-1,\"supportNationwideWarranty\":0,\"town\":\"\",\"townId\":777,\"trackingNumber\":\"YT9105097308687\",\"tradeType\":0,\"updatedAt\":\"2020-02-29 18:37:24\"},{\"address\":\"\",\"afterSalesStatus\":0,\"buyerMemo\":\"\",\"capitalFreeDiscount\":0.0,\"cardInfoList\":[],\"catId1\":7639,\"catId2\":7646,\"catId3\":7861,\"catId4\":8136,\"city\":\"\",\"cityId\":85,\"confirmStatus\":1,\"confirmTime\":\"2020-02-23 20:56:41\",\"country\":\"中国\",\"countryId\":0,\"createdTime\":\"2020-02-22 20:57:35\",\"discountAmount\":0.0,\"freeSf\":0,\"goodsAmount\":12.7,\"groupStatus\":1,\"homeDeliveryType\":0,\"innerTransactionId\":\"XP0020022220200259439068008025\",\"invoiceStatus\":0,\"isLuckyFlag\":1,\"isPreSale\":0,\"isStockOut\":0,\"itemList\":[{\"goodsCount\":1,\"goodsId\":\"8336081475\",\"goodsImg\":\"https://t00img.yangkeduo.com/goods/images/2019-01-11/9710c56f-71c7-4e9d-af37-8773e21138a4.jpg\",\"goodsName\":\"张学友刘德华周杰伦陈奕迅精选汽车CD碟片流行港台明粤语经典老歌\",\"goodsPrice\":12.7,\"goodsSpec\":\"刘德华=2碟\",\"outerGoodsId\":\"\",\"outerId\":\"0\",\"skuId\":\"231294322837\"}],\"lastShipTime\":\"2020-02-26 23:59:59\",\"logisticsId\":85,\"onlySupportReplace\":0,\"orderSn\":\"200222-459201905553404\",\"orderStatus\":3,\"payAmount\":12.7,\"payNo\":\"2020022222001414241423228259\",\"payTime\":\"2020-02-22 20:57:40\",\"payType\":\"ALIPAY\",\"platformDiscount\":0.0,\"postage\":0.0,\"preSaleTime\":\"\",\"province\":\"\",\"provinceId\":6,\"receiveTime\":\"2020-02-29 18:26:52\",\"receiverAddress\":\"\",\"receiverName\":\"\",\"receiverPhone\":\"\",\"refundStatus\":1,\"remark\":\"\",\"returnFreightPayer\":1,\"riskControlStatus\":0,\"selfContained\":0,\"sellerDiscount\":0.0,\"shippingTime\":\"2020-02-25 14:20:44\",\"stockOutHandleStatus\":-1,\"supportNationwideWarranty\":0,\"town\":\"\",\"townId\":777,\"trackingNumber\":\"YT9105097308687\",\"tradeType\":0,\"updatedAt\":\"2020-02-29 18:37:24\"}],\"totalCount\":2}}";
        RestDoing restDoing = jsonResponse -> jsonResponse.setData(JSON.parseObject(s));
        return restDoing.go();
    }
}
